#ifndef _COMMON_DELAY_H_
#define _COMMON_DELAY_H_

#include "common/common_libnamespace.h"

CHENLIB_NAMESPACE_BEGIN

#ifndef WIN32
#include <sys/select.h>
/* According to earlier standards */
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#endif

#ifndef WIN32
	#define DELAY(us) do {	\
		struct timeval timeout = {0};	\
		timeout.tv_sec = us / 1000000;	\
		timeout.tv_usec = us % 1000000;	\
		fd_set fs;	\
		FD_ZERO(&fs);	\
		select(0, NULL, NULL, &fs, &timeout);\
	}while(0)
#else
	#define DELAY(us) do {}while(0)
#endif

CHENLIB_NAMESPACE_END

#endif
